package com.jzo2o.market.controller.consumer;

import com.jzo2o.market.model.dto.request.SeizeCouponReqDTO;
import com.jzo2o.market.model.dto.response.CouponInfoResDTO;
import com.jzo2o.market.service.ICouponService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/consumer/coupon")
public class ConsumerCouponController {
    @Autowired
    private ICouponService couponService;

    /**
     * @param status 状态 1.待使用 2.已使用 3.已过期
     * @param lastId 上次最后查询id
     * @return
     */

    @GetMapping("/my")
    public List<CouponInfoResDTO> getMyCouponList(@RequestParam(required = true) Integer status, @RequestParam(required = false) Long lastId) {
     return couponService.getMyList(status,lastId);
    }

    @ApiOperation("抢券接口")
    @PostMapping("/seize")
    public void seizeCoupon(@RequestBody SeizeCouponReqDTO seizeCouponReqDTO) {
        couponService.seizeCoupon(seizeCouponReqDTO);
    }


}
